home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 4 / The Arsenal Files 4 (Arsenal Computer).ISO / casm / au116-as.exe / UTIL / BBS_FILL.CPP < prev    next >
C/C++ Source or Header  |  1994-12-13  |  5KB  |  205 lines

  1. #include "..\au.hpp"
  2.  
  3. /*************************************************************************/
  4. static void add_to_list2(AU *au, char *dir, char *filespec)
  5. {
  6.     char fname[FLENGTH];
  7.     build_fname(fname, dir, filespec);
  8.     au->process_list.add(fname);
  9. }
  10. /*************************************************************************/
  11. static void fill_list_from_GT(AU *au, char *filespec)
  12. {
  13.     int i, c;
  14.     char string[FLENGTH];
  15.     HANDLE handle;
  16.  
  17.     handle.open(au, "gtdir.bbs");
  18.  
  19.     au_printf_c(au, 15, "GT file directories\n\n");
  20.  
  21.     for (EVER)
  22.     {
  23.         do                  /* go until a space is hit */
  24.         {
  25.             if ((c = handle.read_char()) == EOF)
  26.                 goto Error0;
  27.         } while (c > ' ');
  28.  
  29.         do                  /* go until a non-space is hit */
  30.         {
  31.             if ((c = handle.read_char()) == EOF)
  32.                 goto Error0;
  33.         } while (c <= ' ');
  34.  
  35.         i=0;
  36.         do                  /* go until a space is hit */
  37.         {
  38.             string[i++]=c;
  39.             if ((c = handle.read_char()) == EOF)
  40.                 goto Error0;
  41.         } while (c > ' ');
  42.         string[i]='\0';
  43.         add_to_list2(au, string, filespec);
  44.  
  45.         do                  /* pass over the description */
  46.         {
  47.             if ((c = handle.read_char()) == EOF)
  48.                 goto Error0;
  49.         } while (c != '\n');
  50.     }
  51. Error0:
  52.     handle.close();
  53. }
  54. /*************************************************************************/
  55. /* OPUS version 1.03 & 1.1x */
  56. static void fill_list_from_Opus(AU *au, char *filespec, int is_103, struct ffblk *ffblk)
  57. {
  58.     int i,c;
  59.     HANDLE handle;
  60.     char string[FLENGTH];
  61.  
  62.     au_printf_c(au, 15, "Opus %s file directories\n\n", is_103 ? "1.03" : "1.1x");
  63.  
  64.  /* open up the system files one at a time and pick off the download dir */
  65.     do
  66.     {
  67.          if (strlen(ffblk->ff_name)<11)
  68.              continue;
  69.  
  70.          handle.open(au, ffblk->ff_name);
  71.          handle.seek(is_103 ? 164:130, SEEK_SET);
  72.          {
  73.              i = 0;
  74.              while ((c=handle.read_char()) > ' ')
  75.              {
  76.                  if (c==EOF)
  77.                      break;
  78.                  string[i++] = c;
  79.              }
  80.              string[i] = '\0';
  81.          }
  82.          handle.close();
  83.  
  84.          if (string[0]>33)
  85.              add_to_list2(au, string, filespec);
  86.  
  87.     } while (!findnext(ffblk));
  88. }
  89. /*************************************************************************/
  90. static void fill_list_from_Max(AU *au, char *filespec)      /* Maximus */
  91. {
  92.     long pos = 1378;
  93.     int  version;
  94.     int  ch, ch2;
  95.     char string[FLENGTH];
  96.     HANDLE handle;
  97.  
  98.     handle.open(au, "area.dat");
  99.  
  100.     handle.seek(4L, SEEK_SET);
  101.     ch    = handle.read_char();
  102.     ch2 = handle.read_char();
  103.     if (ch == 0x60 && ch2 == 0x04)
  104.     {
  105.         version = 200;
  106.         pos = 1518;
  107.     }
  108.     else /* (ch == 0xD4 && ch2 == 0x03) */
  109.     {
  110.         version = 102;
  111.         pos = 1378;
  112.     }
  113.     au_printf_c(au, 15, "Maximus %s file directories\n\n", version==102 ? "1.02" : "2.00");
  114.  
  115.     for (EVER)
  116.     {
  117.         handle.seek(pos, SEEK_SET);
  118.         if (handle.read_raw(string, FLENGTH) == 0)
  119.             break;
  120.         if (string[0] != '\0')
  121.             add_to_list2(au, string, filespec);
  122.         pos+= version==102 ? 980 : 1120;
  123.     }
  124.     handle.close();
  125. }
  126. /*************************************************************************/
  127. static void fill_list_from_RBBS(AU *au, char *filespec)    /* RBBS */
  128. {
  129.     long last_comma=0;
  130.     long pos=0;
  131.     int  ch;
  132.     int  i;
  133.     char string[FLENGTH];
  134.     HANDLE handle;
  135.  
  136.     handle.open(au, "rbbs-pc.def", O_BINARY);
  137.  
  138.     au_printf_c(au, 15, "RBBS file directories\n\n");
  139.  
  140.    /* Find the last , *************************/
  141.  
  142.     while ((ch = handle.read_char()) != EOF)
  143.     {
  144.         pos++;
  145.         if (ch == ',')
  146.             last_comma = pos;
  147.     }
  148.  
  149.     handle.seek(last_comma, SEEK_SET);
  150.  
  151.     /* Skip the first 2 quote marks ***********/
  152.  
  153.     for (i=0; i<2; i++)
  154.     {
  155.         while ((ch = handle.read_char()) != '\"')
  156.         {
  157.             if (ch == EOF)
  158.                 goto Error0;
  159.         }
  160.     }
  161.  
  162.     for(EVER)
  163.     {
  164.         i=0;
  165.         while ((ch = handle.read_char()) != '\"')
  166.         {
  167.             if (ch == EOF)
  168.                 goto Error0;
  169.         }
  170.         while ((ch = handle.read_char()) != '\"')
  171.         {
  172.             string[i++] = ch;
  173.             if (ch == EOF)
  174.                 goto Error0;
  175.         }
  176.         string[i] = '\0';
  177.         add_to_list2(au, string, filespec);
  178.     }
  179.  
  180. Error0:
  181.     handle.close();
  182.     return;
  183. }
  184. /*************************************************************************/
  185. void fill_list_from_BBS(AU *au, char *filespec)
  186. {
  187.     struct ffblk ffblk;
  188.  
  189.     if (!findfirst("system*.bbs", &ffblk, 0))
  190.         fill_list_from_Opus(au, filespec, TRUE, &ffblk);
  191.     else if (!findfirst("system*.dat", &ffblk, 0))
  192.         fill_list_from_Opus(au, filespec, FALSE, &ffblk);
  193.     else if (!findfirst("gtdir.bbs", &ffblk, 0))
  194.         fill_list_from_GT(au, filespec);
  195.     else if (!findfirst("area.dat", &ffblk, 0))
  196.         fill_list_from_Max(au, filespec);
  197.     else if (!findfirst("rbbs-pc.def", &ffblk, 0))
  198.         fill_list_from_RBBS(au, filespec);
  199.     else
  200.     {
  201.         au_printf_error(au, "\nNo Recognizable BBS files containing needed directories");
  202.         exit(1);
  203.     }
  204. }
  205.